<?php

/**
 * Description of UploadController
 * 
 * @author anhducbkhn
 * @since Dec 29, 2013 - 10:35:52 PM
 */
class UploadController extends CController
{

    function actionIndex()
    {
        $upload = new Upload;

        $upload->image = CUploadedFile::getInstance($upload, 'image');

        $path = Yii::getPathOfAlias('webroot') . '/' . 'upload';
//        
//        $upload->image->setPath(c);
        $name = rand(1000, 9999) . time(); // rand(1000,9999) optional
        $name = md5($name); //optional
        $upload->image->saveAs($path.'/'.$name.$upload->image);


        $this->render('index', array(
            'file_name' => Yii::app()->homeUrl.'upload' . '/'.$name.$upload->image,
            'result' => 'result',
            'resultcode' => 'notedfailed'
        ));
    }

}

/**
 * End of UploadController
 */